import { tooltipLength, getColorTextLoadMap, renderRegionText } from '@/utils';
import { Tooltip } from 'antd';
import pageStyles from '@/common/pageLayout.less';
import MyIcon from '@/components/MyIcon';

export const supplierColumns = [
  {
    title: '企业名称',
    dataIndex: 'fullName',
    key: 'fullName',
    width: 150,
    visible: true,
    fixed: 'left',
    unDrag: true,
    render: (text: string | null) => {
      return (
        <Tooltip title={text ? tooltipLength(text, 50) : ''}>
          <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
        </Tooltip>
      );
    },
  },
  {
    title: '企业简称',
    dataIndex: 'shortName',
    key: 'shortName',
    width: 120,
    visible: true,
    render: (text: string | null) => {
      return (
        <Tooltip title={text ? tooltipLength(text, 50) : ''}>
          <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
        </Tooltip>
      );
    },
  },
  {
    title: '企业类型',
    dataIndex: 'registerTypeName',
    key: 'registerTypeName',
    width: 120,
    visible: true,
    sorter: (a: any, b: any) => (a?.registerType > b?.registerType ? 1 : -1),
    render: (text: string | null) => {
      const { colorText, color } = getColorTextLoadMap(text);
      return (
        <span
          className={pageStyles['over-flow-hidden']}
          style={{
            color,
          }}
        >
          {colorText ? colorText : '--'}
        </span>
      );
    },
  },
  {
    title: '企业规模',
    dataIndex: 'registerSizeName',
    key: 'registerSizeName',
    width: 120,
    visible: true,
    sorter: (a: any, b: any) => (a?.registerSize > b?.registerSize ? 1 : -1),
    render: (text: string | null) => {
      const { colorText, color } = getColorTextLoadMap(text);
      return (
        <span
          className={pageStyles['over-flow-hidden']}
          style={{
            color,
          }}
        >
          {colorText ? colorText : '--'}
        </span>
      );
    },
  },
  {
    title: '供货分类',
    dataIndex: 'supplyTypeName',
    key: 'supplyTypeName',
    width: 120,
    visible: true,
    sorter: (a: any, b: any) => (a?.supplyType > b?.supplyType ? 1 : -1),
    render: (text: string | null) => {
      const { colorText, color } = getColorTextLoadMap(text);
      return (
        <span
          className={pageStyles['over-flow-hidden']}
          style={{
            color,
          }}
        >
          {colorText ? colorText : '--'}
        </span>
      );
    },
  },
  {
    title: '物料类型',
    dataIndex: 'materialTypeName',
    key: 'materialTypeName',
    width: 120,
    visible: true,
    sorter: (a: any, b: any) => (a?.materialType > b?.materialType ? 1 : -1),
    render: (text: string | null) => {
      const { colorText, color } = getColorTextLoadMap(text);
      return (
        <span
          className={pageStyles['over-flow-hidden']}
          style={{
            color,
          }}
        >
          {colorText ? colorText : '--'}
        </span>
      );
    },
  },
  {
    title: '认证状态',
    dataIndex: 'stateName',
    key: 'stateName',
    width: 120,
    visible: true,
    sorter: (a: any, b: any) => (a?.state > b?.state ? 1 : -1),
    render: (text: string | null) => {
      const { colorText, color } = getColorTextLoadMap(text);
      return (
        <span
          className={pageStyles['over-flow-hidden']}
          style={{
            color,
          }}
        >
          {/* <MyIcon type="icon-dian" style={{ color: color }} /> */}
          {colorText ? colorText : '--'}
        </span>
      );
    },
  },
  {
    title: '经营范围',
    dataIndex: 'businessScope',
    key: 'businessScope',
    width: 200,
    visible: true,
    render: (text: string | null, record: Record<string, any>) => {
      return (
        <Tooltip title={tooltipLength(text, 100)}>
          <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
        </Tooltip>
      );
    },
  },
  {
    title: '所属区域',
    dataIndex: 'provinceCode',
    key: 'provinceCode',
    width: 150,
    visible: true,
    render: (text: string | null, record: Record<string, any>) => {
      let newText: string | null = renderRegionText(record);
      return (
        <Tooltip title={tooltipLength(newText, 100)}>
          <span className={pageStyles['over-flow-hidden']}>{newText ? newText : '--'}</span>
        </Tooltip>
      );
    },
  },
  {
    title: '办公地址',
    dataIndex: 'workAddress',
    key: 'workAddress',
    width: 150,
    visible: true,
    render: (text: string | null, record: Record<string, any>) => {
      return (
        <Tooltip title={tooltipLength(text, 100)}>
          <span className={pageStyles['over-flow-hidden']}>{text ? text : '--'}</span>
        </Tooltip>
      );
    },
  },
];
